home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 429 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: clamage@Eng.sun.com (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: virtual base class initialization
  5. Date: 21 Feb 1996 21:03:09 GMT
  6. Organization: Sun Microsystems Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4gfs4g$ju2@engnews1.Eng.Sun.COM>
  9. References: <199602211555.IAA16749@ncar.ucar.EDU>
  10. Reply-To: clamage@Eng.sun.com
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: taumet.eng.sun.com
  14. Content-Length: 902
  15. X-Lines: 27
  16. Originator: clamage@taumet
  17.  
  18. In article IAA16749@ncar.ucar.EDU, weber@ezibk8.vmsmail.ethz.ch writes:
  19. >// I am not sure how to interprate the ARM (or the Draft C++ Standard) 
  20. >// with regard to the initialization of a virtual base class.
  21. >
  22.  ... V is a virtual base class of A
  23.  
  24. >class C2: public A, public B{
  25. >public:
  26. >    C2(int i): A(i){}
  27. >};
  28. >
  29. >// C2 is not directly derived from V. In this case I don't think the base
  30. >// class should still be initialized by the most derived class.
  31.  
  32. Yes it should. The most-derived class initializes all the virtual base
  33. classes in its hierarchy, whether the virtual base classes are direct
  34. base classes or not. None of the intermediate base classes initialize
  35. any of the virtual base classes.
  36.  
  37. It would be possible to define other (probably more complicated) rules
  38. to specify a different order of initialization, but that is the C++ rule.  
  39.  
  40. ---
  41. Steve Clamage, stephen.clamage@eng.sun.com
  42.  
  43.  
  44.  
  45. [ To submit articles: Try just posting with your newsreader.
  46.               If that fails, use mailto:std-c++@ncar.ucar.edu
  47.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  48.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  49.   Comments? mailto:std-c++-request@ncar.ucar.edu
  50. ]
  51.